package br.com.javamagazine.leilaojm.ejb;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import br.com.javamagazine.leilaojm.domain.*;

@Stateless
public class ModeloService {

	@PersistenceContext
	private EntityManager entityManager;

	public void salvarModelo(Modelo modelo) {
		entityManager.persist(modelo);
	}

	@SuppressWarnings("unchecked")
	public List<Modelo> listaModelos() {
		Query query = entityManager
				.createQuery("Select m from Modelo m order by m.nome");
		return query.getResultList();
	}

	@SuppressWarnings("unchecked")
	public List<Marca> listaMarcas() {
		Query query = entityManager
				.createQuery("Select m from Marca m order by m.nome");
		return query.getResultList();
	}

}
